package org.mtmi.ui.drawables;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.mtmi.ui.controls.Knob;
import org.mtmi.ui.scenes.COLOR;

/**
 * Display an image of knob color .
 */
public class KnobColorDrawable extends AbstractColorDrawable 
{
	
	/** caller is responsible to dispose color */
	public KnobColorDrawable( Color clr ) {
		super( clr );
	}
	
	@Override
	public void paint( GC gc, int x, int y, int width, int height, int state ) {
		//a square:
		int r = Math.min( width, height );
		int cx = x+width/2;
		int cy = y+height/2;
		
		//can grow area, because knob radius is fraction of square
		r = 3*r/2;
		
		/*gc.setBackground( COLOR.grey100 );
		gc.fillRectangle( x, y, width, height );
		gc.setBackground( COLOR.grey20 );
		int r4=r-4;
		gc.fillRectangle( x+2, y+2, r4, r4 );*/
		
		gc.setLineWidth( 2 );
		gc.setBackground( color );
		gc.setForeground( COLOR.grey20 );
		Knob.drawKnob( gc, cx, cy, r, r, 0, 33, 100, -135, 270 );
		
		/*Color cl = CLR.lighter( color, 0.3f );
		Color cd = CLR.darker( color, 0.3f );
		if( r >= 14 ) {
			//gc.setBackground( color );
			int r8 = r-8;
			//gc.fillRectangle( x+4, y+4, r8, r8 );
			gc.setForeground( cl );
			gc.setBackground( cd );
			gc.fillGradientRectangle( x+4, y+4, r8, r8, true );
		} else {
			//gc.setBackground( color );
			//gc.fillRectangle( x, y, r, r );
			gc.setForeground( cl );
			gc.setBackground( cd );
			gc.fillGradientRectangle( x, y, r, r, true );
		}*/
	}

}
